Attribute VB_Name = "FirefoxHelper"
Public Sub Firefox(url As String)
    ' Ask Firefox to open a URL.
    ' Local files may be specified as a complete path without a method prefix,
    ' e.g., "C:\some directory\foobar.html".
    ' We will add the FILE:// method string to the front of the URL and encode blank characters.
    ' If a method is present, e.g., "HTTP://whatever", we will NOT encode anything.
    Dim xl As Application
    Dim channel As Integer
    Dim colonPos As Integer
    If url = "" Then Exit Sub  ' no argument supplied
    ' If there is no URL method, add FILE and encode the string.
    ' Otherwise, assume the string is alright as is.
    colonPos = InStr(1, url, ":", vbTextCompare)
    If colonPos = 0 Or colonPos = 2 Then  ' no colon or "<drive letter>:"
        ' No method present.
        url = "FILE://" & url  ' add FILE method and separator
        url = Replace(url, " ", "%20", 1, -1, vbTextCompare)  ' encode blanks
        ' We should encode other characters...
    End If
    Debug.Print url
    Set xl = Application
    channel = xl.DDEInitiate("Firefox", "WWW_OpenURL")
    xl.DDEExecute channel, url & ",,0,0,,,,"
    xl.DDETerminate channel
End Sub
